//
//  Data.m
//  UI15_太平洋电脑网
//
//  Created by dllo on 16/3/24.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "Data.h"

@implementation Data
+ (void)netWorkingWithURL:(NSString *)strUrl block:(void (^)(id result))block{
    NSURL *url = [NSURL URLWithString:strUrl];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
    NSURLSession *session = [NSURLSession sharedSession];
    NSURLSessionTask *task = [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        
        dispatch_queue_t queue = dispatch_get_main_queue();
        dispatch_async(queue, ^{
            id result = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
            block(result);
        });
        
    }];
    [task resume];
}

@end
